<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
  <title>众茶国际</title>

  <script src="../vueJS/vue.js"></script>  
  <!-- 引入样式 -->
  <link rel="stylesheet" href="../ElementUI/index.css">
  <!-- 引入组件库 -->
  <script src="../ElementUI/index.js"></script>
</head>
<body>
  <div id="app">
    <div v-if="isShowInfo">
      <div class="info">
        <i style="font-size:104px; color: rgb(48, 159, 253);" class="el-icon-warning-outline"></i>
      </div>
      <div class="title"><span class="tips">请在微信客户端扫码打开链接</span></div>
    </div>
  </div>
</body>

<script type="text/javascript">
  new Vue({
    el:'#app',
    data:{
      isShowInfo:false,
      url: "",
      appIntegral: '',
    },
    computed: {},
    watch: {},
    methods: {
      GetUrlParam(name) {
        // 用该属性获取页面 URL 地址从问号 (?) 开始的 URL（查询部分）
        var url = window.location.search;
        // 正则筛选地址栏
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        // 匹配目标参数
        var result = url.substr(1).match(reg);
        //返回参数值
        return result ? decodeURIComponent(result[2]) : null;
      }
    },
    created() {
      var H5PayCode = this.GetUrlParam("H5PayCode")
      console.log("参数H5PayCode:" ,H5PayCode);
      
      var ua = window.navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        var targetUrl = "https://www.utea88.com/static/H5Pay/WXLoginSuccess.html?H5PayCode=" + H5PayCode

        this.isShowInfo = false;

        this.url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" 
        + "wx0ef0b183470e3032" + 
        "&redirect_uri=" + encodeURIComponent(targetUrl) 
        + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"

        window.location.href = this.url
      } 
      else if (ua.match(/Alipay/i)=="alipay") {
        // alert('支付宝端打开‘); 
        var targetUrl  = "https://www.utea88.com/static/H5Pay/AliH5LoginSuccess.html?H5PayCode=" + H5PayCode
        this.url = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021002143605589&scope=auth_base&redirect_uri="
        + encodeURIComponent(targetUrl) 
        window.location.href = this.url
      } else {
        this.isShowInfo = true
      }
    },
    mounted() {
      
    },
  })
</script>

<style lang='scss' scoped>
  .info {
    display: flex;
    justify-content: center;
    margin-top: 35px;
    width: 100%;
  }

  .title {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    width: 100%;
  }

  .tips {
    font-weight: 400;
    font-size: 20px;
    color: black;
  }
</style>
</html>